﻿<%@ WebHandler Language="C#" Class="Training.Web.AjaxHandler.Loaddata.Administration.Catalog.BagianLoadHandler" %>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Configuration;
using System.Text;

using Training.Library.DataAccess.Administration;
using Training.Library.DomainObject.Administration;
using Training.Library.DataAccess.Administration.Catalog;
using Training.Library.DomainObject.Administration.Catalog;

using Training.Library.Enum;
using Training.Web.Support;

using Newtonsoft.Json.Linq;

namespace Training.Web.AjaxHandler.Loaddata.Administration.Catalog
{

    public class BagianLoadHandler : Training.Web.BaseHandler
    {

        BagianRepo BagianDal = new BagianRepo(ConfigurationManager.ConnectionStrings["TrainingConn"].ConnectionString);
        string MethodName = string.Empty;

        public override void ProcessRequest(HttpContext context)
        {
            base.ProcessRequest(context);

            if (context.Request.Params["method"] != null)
                MethodName = context.Request.Params["method"];

            if (MethodName == "getbydepartment")
            {
                int departmentID = Convert.ToInt32(context.Request.Params["departmentID"].ToString());
                List<Bagian> list = BagianDal.GetList();
                var result = list.Where(x => x.DepartmentID == departmentID); ;
                context.Response.Write(Newtonsoft.Json.JsonConvert.SerializeObject(result));

            }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }

    }
}